package com.example.download;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.net.InetAddress;
import java.net.UnknownHostException;

@EnableSwagger2
@SpringBootApplication
public class DownloadApplication {

    public static void main(String[] args) throws UnknownHostException {

        ConfigurableApplicationContext context = SpringApplication.run(DownloadApplication.class, args);
        ConfigurableEnvironment env = context.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");


        System.out.println("\n----------------------------------------------------------\n\t" +
                "swagger访问地址: \thttp://localhost:" + port + path +"swagger-ui.html"+ "\n\t" +
                "访问访问地址: \t\thttp://localhost:" + port + path + "\n\t" +
                "IP访问访问地址: \t\thttp://" + ip + ":" + port + path + "\n\t" +
                "----------------------------------------------------------");
    }

}
